import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:x_common_utils/utils/inkWell_util.dart';
import 'package:xinxuan/common/button_util.dart';
import 'package:xinxuan/controllers/home_controller/home_page_controller.dart';
import 'package:xinxuan/router/app_routers.dart';
import 'package:xinxuan/utils/color_util.dart';
import 'package:xinxuan/utils/dialog_queue_manager_util.dart';

class ActivityDialog extends StatelessWidget {

  final HomePageController homePageController = Get.find();

  final String title;
  final String description;
  ActivityDialog({
    required this.title,
    required this.description,
  });

  @override
  Widget build(BuildContext context) {
    return Material(
      type: MaterialType.transparency,
      child: Center(
        child: Stack(
          children: [
            Container(
              padding: EdgeInsets.symmetric(horizontal: 8.w),
              child: Stack(
                children: [
                  Column(
                    mainAxisSize: MainAxisSize.min,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      SizedBox(height: 92.h),
                      Container(
                        width: 320.w,
                        alignment: Alignment.center,
                        decoration: BoxDecoration(
                          color: bgWhiteColor,
                          borderRadius: BorderRadius.circular(8.w)
                        ),
                        child: Column(
                          children: [
                            SizedBox(height: 87.h),
                            Container(
                              height: 46.h,
                              alignment: Alignment.center,
                              child: Text(
                                '$title',
                                maxLines: 1,
                                overflow: TextOverflow.ellipsis,
                                style: TextStyle(
                                  color: textBlackColor,
                                  fontSize: 16.sp,
                                  fontWeight: FontWeight.bold
                                ),
                              )
                            ),
                            Container(
                              padding: EdgeInsets.symmetric(horizontal: 20.w),
                              alignment: Alignment.topLeft,
                              child: Text(
                                '$description',
                                textAlign: TextAlign.left,
                                style: TextStyle(
                                  fontSize: 14.sp,
                                  color: textBlackColor
                                ),
                              ),
                            ),
                            Container(
                              width: 153.w,
                              padding: EdgeInsets.only(bottom: 32.h, top: 20.h),
                              child: ButtonUtil(
                                text: '立即参加', 
                                fontSize: 14.sp, 
                                borderRadius: 30.h, 
                                height: 30.h, 
                                onTop: () {
                                  Get.back();
                                  // 出队
                                  DialogQueueManager.dequeue();
                                  Get.toNamed('${AppRouters.COMMON_PAGE}${AppRouters.ACTIVTY_PAGE}');
                                }
                              ),
                            )
                          ],
                        ),
                      ),
                    ],
                  ),
                  Positioned(
                    top: 0,
                    child: Image.asset(
                      'assets/images/image_activity_bg.png',
                      width: 320.w,
                      height: 179.h,
                      fit: BoxFit.fill,
                    )
                  ),
                ],
              ),
            ),
            Positioned(
              right: 0,
              top: 76.h,
              child: InkWellUtil.shakeProofInkWell(Image.asset(
                'assets/icons/icon_close_w.png',
                width: 30.w,
                height: 30.w,
              ), () {
                Get.back();
              },
              hoverColor: Colors.transparent,
              splashColor: Colors.transparent,
              highlightColor: Colors.transparent)
            )
          ],
        ),
      ),
    );
  }
}